package hello;

import java.awt.image.BufferedImage;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.net.URL;
import java.net.URLConnection;

import javax.imageio.ImageIO;

public class testFileSize {
	public static void main(String[] args) throws FileNotFoundException, IOException {

		URL url = new URL("http://buyixinlingshou.oss-cn-beijing.aliyuncs.com/%E7%81%AB%E7%83%88%E9%B8%9F_12-68acd813bdd3.jpg");
		URLConnection connection = url.openConnection();
		connection.setDoOutput(true);
		BufferedImage image = ImageIO.read(connection.getInputStream());
		int srcWidth = image.getWidth(); // 源图宽度
		int srcHeight = image.getHeight(); // 源图高度

		int length = connection.getContentLength();
        System.out.println("length: " + String.format("%.1f",length/1024.0));
        
		System.out.println("srcWidth = " + srcWidth);
		System.out.println("srcHeight = " + srcHeight);

	}
}
